package com.comp437.uno.model.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class ConnectionHelper {
	 public static boolean isConnectingToInternet(Context _context){
	        //Toast.makeText(Home.this, "10%", Toast.LENGTH_SHORT).show();
	        ConnectivityManager connectivity = (ConnectivityManager) _context.getSystemService(Context.CONNECTIVITY_SERVICE);
	        //Toast.makeText(Home.this, "20%", Toast.LENGTH_SHORT).show();
	          if (connectivity != null)
	          {
	              //Toast.makeText(Home.this, "30%", Toast.LENGTH_SHORT).show();
	              NetworkInfo[] info = connectivity.getAllNetworkInfo();
	              if (info != null){
	                  //Toast.makeText(Home.this, "70%", Toast.LENGTH_SHORT).show();
	                  for (int i = 0; i < info.length; i++)
	                      if (info[i].getState() == NetworkInfo.State.CONNECTED)
	                      {
	                         return true;
	                      }
	              }
	          }
	         return false;
	    }
}
